In a CCD or CMOS image sensor, the optical dark level is usually non-zero and needs to be subtracted from the normal ADC output level in order to obtain the true signal level. To obtain appropriate estimate of this optical dark level, multiple samples at various places in the sensor array are taken and assessed. The most commonly used method is to perform an averaging operation on these samples, either using an analog integration circuit or digital accumulator. However, if one or more of the sample points is a defect pixel the averaged measurement will be biased and the entire image will either become too dark or too bright. Defect pixels occur quite often in the sensor array and can be the result of imperfect black filters, which causes light leak, or blooming due to neighboring saturated pixels, among other things. The occurrence of defect pixels may distort the estimated dark level enough to render the chip unusable.